<template>
	<om-formsub-outer :index="index" :checkedit="checkedit">
		<om-autoform ref="autoform" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {buildSubFormData, subOnLoad, changeEditor,configSelectData,hasValue} from '../../../static/js/formUtil.js';
	import { ignoreHtml,ptFloat,minusF,getDateStr} from '@/static/js/common.js';
	import { mapState } from 'pinia';
	import {useLoginUserStore} from '@/stores/login-user.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				productCache:"mkt-dd-salesOrderReview-title8-product-cache"
			})
		},
		computed:{
			...mapState(useLoginUserStore, [ 'userId'])
		},
		methods:{
			
		},
		onShow() {
			let _that = this
			if(_that.$refs.autoform){
				uni.getStorage({
					key:_that.productCache,
					success:(res)=>{
						if(res.data){
							let d = res.data
							let formdata = _that.$refs.autoform.formdata
								formdata.materielId = d.id
								formdata.materielCode = d.projectCode
								formdata.materielName = d.projectName
								formdata.materielStd = d.projectStd
								formdata.rowNum = d.materielNum
								formdata.materielUnit = d.mainUnitName
							uni.removeStorage({
								key:_that.productCache
							})
						}
					}
				})
			}
		},
		onLoad(e) {
			let _that = this
			subOnLoad(_that, e, function() {
			if(e.configDataCacheKey){
				uni.getStorage({
					key: e.configDataCacheKey,
					success: function(res) {
						if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
							_that.autoformdata = res.data
							Object.assign(_that.initValue, _that.formdata)
							_that.autoformdata[0].order = _that.order
							changeEditor("title8","materielId",{
								link:'../../public/pageSearch/pageSearch',
								"linkParam":{
									other:JSON.stringify({
										
									}),
									url:"productShow/likeSerchPager",
									initload:true,
									namefield:"projectCode",
									notefield:"projectName",
									extrafield:"projectMnemonic",
									cachename:_that.productCache,
								}
							},null,_that.autoformdata)
							}
						}
					})
					_that.$nextTick(function(){
						if(_that.checkedit && _that.userId == _that.$refs.autoform.formdata.planUserId || !_that.$refs.autoform.formdata.planUserId){
							_that.$refs.autoform.changeEditor("title8","materielId","checkedit",true)
							_that.$refs.autoform.changeEditor("title8","materielNum","checkedit",true)
							_that.$refs.autoform.changeEditor("title8","expectArrivalDate","checkedit",true)
							_that.$refs.autoform.changeEditor("title8","materielRemark","checkedit",true)
						}
					})
				}
			})
		}
	}
</script>

<style>
</style>                                                                                                                                                                                                                                                                                                                                                                                                                                                  
